typedef uint16_t SUMMARY_VALUE;

#define SUMMARY_SIZE 16                     // size of summary, in bytes
#define SUMMARY_LEN (SUMMARY_SIZE / sizeof(SUMMARY_VALUE))  // max entries in summary that can be maintained as a list
                                            // assume two byte elements
#define SUMMARY_BLOOMFILTER      0          // types of summaries supported
#define SUMMARY_COUNTHISTOGRAM   1
#define SUMMARY_EXISTHISTOGRAM   2
#define SUMMARY_RTREE            3

#define BLOOMFILTER_FUNCTIONS 2
#define SUMMARY_PRIME1 113                  // for Bloom Filter hashing
#define SUMMARY_PRIME2 127

typedef struct {
  uint8_t type, options;
  uint16_t count;
  SUMMARY_VALUE summary[SUMMARY_LEN];
} PACKING_MACRO SUMMARY;

void summary_init(SUMMARY *s, uint8_t type, uint8_t options);
void summary_add(SUMMARY *s, SUMMARY_VALUE v);
uint8_t summary_test(SUMMARY *s, SUMMARY_VALUE v, uint16_t options);
uint8_t summary_testrange(SUMMARY *s, SUMMARY_VALUE lo, SUMMARY_VALUE hi, uint16_t options);
void summary_merge(SUMMARY *s1, SUMMARY *s2);
uint8_t summary_equal(SUMMARY *s1, SUMMARY *s2);

void summary_print(SUMMARY *s);

